package itbour.onetouchshow.activity.userinfo;

import android.os.Build;

import com.google.gson.Gson;
import com.lsjr.callback.EncryBeanCallBack;
import com.lsjr.utils.HttpUtils;

import java.util.HashMap;

import itbour.onetouchshow.App;
import itbour.onetouchshow.base.mvp.BasePresenterImpl;
import itbour.onetouchshow.bean.PhoneDevInfoBean;
import itbour.onetouchshow.constants.AppConfig;
import itbour.onetouchshow.constants.AppConst;
import itbour.onetouchshow.utils.DeviceUtil;
import itbour.onetouchshow.utils.L_;
import itbour.onetouchshow.utils.T_;
import itbour.onetouchshow.utils.UIUtils;

/**
 * MVPPlugin
 * 邮箱 784787081@qq.com
 */

public class UserinfoPresenter extends BasePresenterImpl<UserinfoContract.View> implements UserinfoContract.Presenter {
    public void upDateUserInfo(String userName, String sign, String avatarUrl) {
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("device", AppConst.ANDROID_DEVICE);
        stringObjectHashMap.put("userId", App.getUserId());
        stringObjectHashMap.put("nickName", userName);
        stringObjectHashMap.put("avatarUrl", avatarUrl);
        stringObjectHashMap.put("sign", sign);
        L_.e("UserinfoPresenter upDateUserInfo" + sign);
        L_.e("UserinfoPresenter nickName" + sign);
        HttpUtils.getInstance().executeGet(AppConfig.UPDATEUSERINFO_V1_0, stringObjectHashMap, new EncryBeanCallBack() {
            @Override
            protected void onXError(String exception) {
                T_.showCustomToast(exception);
            }

            @Override
            protected void onSuccess(String response) {


                L_.e("" + response);
                mvpView.loadSucceed(response);

            }
        });
    }


    public void upLoadFeedBack(String context, String deviceDesc, String imageUrls, String phone) {

        String appVersionName = DeviceUtil.getAppVersionName(UIUtils.getContext());
        //手机型号
        String model = Build.MODEL;
        //系统版本
        String release = Build.VERSION.RELEASE;
        PhoneDevInfoBean phoneDevInfoBean = new PhoneDevInfoBean(model, release, appVersionName);
        String deviceInfo = new Gson().toJson(phoneDevInfoBean);
        L_.e("deviceInfo===" + deviceInfo);
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("deviceInfo", deviceInfo);
        stringObjectHashMap.put("device", AppConst.ANDROID_DEVICE);
        stringObjectHashMap.put("userId", App.getUserId());
        stringObjectHashMap.put("text", context);
        stringObjectHashMap.put("deviceDesc", deviceDesc);
        // stringObjectHashMap.put("images", imageUrl);
        stringObjectHashMap.put("images", imageUrls);
        stringObjectHashMap.put("mobile", phone);

        HttpUtils.getInstance().executeGet(AppConfig.SENDFEEDBACK_V1_0, stringObjectHashMap, new EncryBeanCallBack() {
            @Override
            protected void onXError(String exception) {

            }

            @Override
            protected void onSuccess(String response) {
                mvpView.loadSucceed(response);
            }
        });
    }
}
